//
//  FQBorrowChildListViewController.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/8/23.
//

import UIKit

enum BorrowChildListType : Int {
    case record = 0
    case withdrawal
    case refund
}

class FQBorrowChildListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, JXSegmentedListContainerViewListDelegate {
    let mainTable = UITableView(frame: .zero, style: .plain)
    weak var viewController : UIViewController!
    var borrowType : BorrowChildListType = .record
    
    convenience init(_ type : BorrowChildListType) {
        self.init(nibName: nil, bundle: nil)
        borrowType = type
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBarType = .light
    }
    
    override func initSubviews() {
        super.initSubviews()
        
        mainTable.dataSource = self
        mainTable.delegate = self
        mainTable.separatorStyle = .none
        mainTable.backgroundColor = view.backgroundColor
        mainTable.register(FQWithdrawalTableViewCell.self, forCellReuseIdentifier: "withdrawal")
        view.addSubview(mainTable)
        
        switch borrowType {
        case .record:
            mainTable.rowHeight = 132
        case .withdrawal:
            mainTable.rowHeight = 132
        case .refund:
            mainTable.rowHeight = 132
        }

        mainTable.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        showEmptyView(with: UIImage(named: "mine_borrowList_empty"), text: nil, detailText: nil, buttonTitle: nil, buttonAction: nil)
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        10
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//        switch borrowType {
//        case .withdrawal:
//            let cell = tableView.dequeueReusableCell(withIdentifier: "withdrawal") as! FQWithdrawalTableViewCell
//            return cell
//        default:
            return UITableViewCell()
//        }
    }
    
    func listView() -> UIView {
        view
    }
    
    override func setupNavigationItems() {
        super.setupNavigationItems()
        switch borrowType {
        case .record:
            title = "申请记录"
        case .withdrawal:
            title = "待提现"
        case .refund:
            title = "待还款"
        }
    }
}
